/**
 * 
 */
package t4j.generics;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Set;

import t4j.generics.coffee.Coffee;
import t4j.generics.coffee.CoffeeGenerator;
import t4j.net.mindview.util.CountingGenerator;
import t4j.net.mindview.util.Generator;

/**
 * @author sz
 *
 * create time：2013-1-5
 */
public class E13_OverloadedFill {
	public static <T> List<T> 
	  fill(List<T> list, Generator<T> gen, int n) { 
	    for(int i = 0; i < n; i++) 
	      list.add(gen.next()); 
	    return list; 
	  } 
	  public static <T> Queue<T> 
	  fill(Queue<T> queue, Generator<T> gen, int n) { 
	    for(int i = 0; i < n; i++) 
	      queue.add(gen.next()); 
	    return queue; 
	  } 
	  public static <T> LinkedList<T> 
	  fill(LinkedList<T> llist, Generator<T> gen, int n) { 
	    for(int i = 0; i < n; i++) 
	      llist.add(gen.next()); 
	    return llist; 
	  } 
	  public static <T> Set<T> 
	  fill(Set<T> set, Generator<T> gen, int n) { 
	    for(int i = 0; i < n; i++) 
	      set.add(gen.next()); 
	    return set;
	  } 
	  public static void main(String[] args) { 
	    List<Coffee> coffeeList = fill( 
	      new ArrayList<Coffee>(), new CoffeeGenerator(), 4); 
	    
	    for(Coffee c : coffeeList) 
	      System.out.println(c); 
	    
	    Queue<Integer> iQueue = fill( 
	      new LinkedList<Integer>(), 
	      new Fibonacci(), 12); 
	    
	    for(int i : iQueue) 
	      System.out.print(i + " "); 
	    
	    System.out.println(); 
	    
	  }
}
